/***************************************************************************
 创建者: 华磊
 开始时间: 2020.8.14
 copyright: (C) 深圳市华友高科有限公司
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2020.5.8 类的具体实现代码编写

 ***************************************************************************/
#include "mapview.h"
#include "ui_mapview.h"
#include <QGraphicsRectItem>
#include <qpen.h>
#include <qdebug.h>
#include "vehicleitem.h"
#include "basemapimage.h"
#include "mapscene.h"
#include "maplogic.h"
#include "mapgraphicsview.h"
#include "balljoystick.h"
#include <QGraphicsPolygonItem>
//#include "mapdelegate.h"
#include "mapedittoolbox.h"
#include "../CommunicateDelegate/globaldata.h"
#include "qsettings.h"
#include "qfiledialog.h"
#include "mapdelegate.h"
#include <QMessageBox>
#include "../CommunicateDelegate/filedata.h"
#include "../FtpManage/ftpmanage.h"


#include "hmicommondefine.h"
#include "instructionEnum.h"
#include "reflecteditdialog.h"
#ifdef D_USE_FLEET_WINDOW
#include "mainwindowfleet.h"
#endif

#include "../WindowShowManage/windowshowmanage.h"
#define IF_FOR_AGV_STYLE 1

extern WindowShowManage *g_windowShowManage;


extern FtpManage *ftpManage;
extern FileData fileData;

enum E_AGV_STATE
{
    E_AGV_STATE_IDILE=0,
    E_AGV_STATE_MOVING=1,
    E_AGV_STATE_LOSE_POSITION=2,
    E_AGV_STATE_LASER_CEASE=3,
    E_AGV_STATE_LASER_STOP=4,
    E_AGV_STATE_INFRARED_STOP=5,
    E_AGV_STATE_ULTRASONIC_STOP=6,
    E_AGV_STATE_CHARGING=7,
    E_AGV_STATE_CEASE=8,
    E_AGV_STATE_EMERGENCE_STOP=9,
    E_AGV_STATE_COMMAND_READY=10,
    E_AGV_STATE_ULTRASONIC_CEASE=100,
    E_AGV_STATE_INTERNAL_ERROR=101,

};

MapView::MapView(MapDelegate *mapDelegateIn,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MapView)
{
    ui->setupUi(this);

    mapDelegate=mapDelegateIn;

    scaleRatio=1;
    rotateAngel=0;
    xOffset=0;
    yOffset=0;
    jogFlag=0;

    car_positionX_M=0;
    car_positionY_M=0;
    car_positionA_M=0;

    model_vmarksInfoInfo= new QStandardItemModel();
    model_vmarksDebugInfo= new QStandardItemModel();
    model_qrcodeDebugInfo= new QStandardItemModel();
    model_amclDebugInfo= new QStandardItemModel();

    mapLogic=new MapLogic();
    scene=new MapScene(mapLogic);
    scene->setSceneRect(0,0, mapLogic->getMapWidth(),mapLogic->getMapHeight());
    mapGraphicsView=new MapGraphicsView(scene,ui->tabWidget->widget(0));

    mapGraphicsView->setGeometry(0,0,730,590);//会盖住缩放按钮

    ballJoyStick=new BallJoyStick(300,this);

    mapEditToolBox=new MapEditToolBox(this);
//    ui->dockWidget_tool->setFeatures(QDockWidget::DockWidgetMovable);
////    ui->dockWidget_tool->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
////    ui->dockWidget_tool->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable);
//    ui->dockWidget_tool->setFeatures(QDockWidget::AllDockWidgetFeatures);
//    ui->dockWidget_tool->setWidget(mapEditToolBox);

    ui->toolBox_container->removeItem(0);
    ui->toolBox_container->addItem(mapEditToolBox,"地图工具");

    reflectEditDialog=new ReflectEditDialog(mapDelegate,scene,this);

//    mapManagementView=new CreateMapView(this);
//    ui->verticalSlider_speed->setRange(0,100);
//    ui->verticalSlider_speed->setValue(30);

    ui->verticalSlider_speed_jog->setRange(1,100);
    ui->verticalSlider_speed_jog->setSingleStep(1);
    ui->verticalSlider_speed_jog->setPageStep(1);
    ui->verticalSlider_speed_jog->setValue(50);

    ui->verticalSlider_speed_jog_Edit->setValidator(new QIntValidator(0, 100, this));
    ui->verticalSlider_speed_jog_Edit->setText(QString::number(50));

    initialFleetWindow();

//    initialCar();
//    initialLaserPoint();

    timer = new QTimer();
    connect(timer,SIGNAL(timeout()),this,SLOT(timeroutslot()));//timeoutslot()为自定义槽,不能用,Qt::BlockingQueuedConnection
//    connect(scene,SIGNAL(updatePointsSignal()),this,SLOT(showPointsInMap_Slot()));
    connect(mapEditToolBox,SIGNAL(setLandPointShow(bool)),this,SLOT(setShowLandPoint_Slot(bool)));
    connect(mapEditToolBox,SIGNAL(setChangeOriginalLaserFilter_signal(int)),this,SLOT(setChangeOriginalLaserFilter_slot(int)));
    connect(mapEditToolBox,SIGNAL(setShowReflectDialog_signal(bool)),this,SLOT(setShowReflectDialog_Slot(bool)));
    connect(reflectEditDialog,SIGNAL(displayAllReflectMarksInMap_signal(bool)),this,SLOT(displayAllReflectMarksInMap_slot(bool))
            ,Qt::DirectConnection);

    connect(mapEditToolBox,SIGNAL(setShowNormalPositionCircule_signal(bool)),this,SLOT(setShowNormalPositionCircule_slot(bool)));
    connect(mapEditToolBox,SIGNAL(setShowReflectPositionCircule_signal(bool)),this,SLOT(setShowReflectPositionCircule_slot(bool)));
    connect(mapEditToolBox,SIGNAL(setShowReflectCar_signal(bool)),this,SLOT(setShowReflectCar_slot(bool)));
    connect(mapEditToolBox,SIGNAL(setShowCommonCar_signal(bool)),
            this,SLOT(setShowCommonCar_slot(bool)));

    if(IF_FOR_AGV_STYLE)
    {
        QObject::connect(this,SIGNAL(loginControllerSucess_signal()),
                         mainWindowFleet, SLOT(loginControllerSucess_slot() ));

        QObject::connect(scene,SIGNAL(userPointClicked_signal(double,double ,double)),
                         reflectEditDialog, SLOT(useUserPoint_slot(double,double ,double) ));

    }

    initialShowStyle();

}

MapView::~MapView()
{
    delete ui;
}

int MapView::reloadMap()
{
//    qDebug()<<"MapView::reloadMap"<<mapPath;
    if(mapDelegate->get_isDisplayAllReferenceMarks())
    {
        displayAllReflectMarksInMap_slot(true);
    }
    //gsoap读取
    MapPropertyInfo infoOut;
    mapDelegate->getMapPropertyInfo("",infoOut);
    return scene->reloadMap(infoOut);
}



//int MapView::drawCar(double x_pix, double y_pix, double a_degree)
//{
//    double px,py,pa;

//    if(NULL!=carBorder)
//    {
//        QMatrix tmpMatrixIn;
//        mapLogic->calculateCarTransMatrix(x_pix,y_pix,a_degree,tmpMatrixIn);
//        carBorder->setMatrix(tmpMatrixIn);
////        carBorder->setPos(px,py);
////        carBorder->setRotation(pa);
//        car_text->setMatrix(tmpMatrixIn);
//    }

//    return 1;


////    if(NULL!=car_front)
////    {
////        scene->removeItem(car_front);

////        scene->removeItem(car_back);
////        scene->removeItem(car_left);
////        scene->removeItem(car_right);
////        scene->removeItem(car_text);
////    }
////    QVector<double> tmpX;
////    QVector<double> tmpY;
////    mapLogic->calculateCarPoint(x,y,a,tmpX,tmpY);
////    car_front = scene->addLine(tmpX[0],tmpY[0], tmpX[1],tmpY[1]);
////    car_back = scene->addLine(tmpX[2],tmpY[2], tmpX[3],tmpY[3]);
////    car_left =  scene->addLine(tmpX[0],tmpY[0], tmpX[2],tmpY[2]);
////    car_right = scene->addLine(tmpX[1],tmpY[1], tmpX[3],tmpY[3]);
////    QFont tmpFont;
////    tmpFont.setPointSize(50);
////    car_text=scene->addText("A",tmpFont);
////    car_text->setPos(tmpX[0],tmpY[0]);
////    return 1;

////    vehicleItem->setPosition(x,y,a);
////    ui->graphicsView->show();
////    update();
//    //    repaint();
//}

//int MapView::drawLaserPoint(std::vector<PointCloudData_3D> &pointCloudOut, double x, double y, double a)
//{
//    //注意屏幕坐标系是左手坐标系，ｒｏｓ里面时右手坐标系
//    if(pointCloudOut.size()<=0)
//    {
//        return -1;
//    }

//    QPointF tmpPointF1(0,0);
//    QVector<QPointF> tmpPointFVector;

//    int laserCount=pointCloudOut.size();
//    for(int laserIndex=0;laserIndex<laserCount;laserIndex++)
//    {
//        int pointCount=pointCloudOut[laserIndex].point_x.size();
//        for(int i=0;i<pointCount;i++)
//        {
//            tmpPointF1.setX(pointCloudOut[laserIndex].point_x[i]/mapLogic->getMapResolution());
//            tmpPointF1.setY(-pointCloudOut[laserIndex].point_y[i]/mapLogic->getMapResolution());
//            tmpPointFVector.append(tmpPointF1);
//        }
//    }
//    QPolygonF tmpPolygon(tmpPointFVector);
//    laserPointPolygon->setPolygon(tmpPolygon);
//    if(NULL!=laserPointPolygon)
//    {
//        QMatrix tmpMatrixIn;
//        double x_out,y_out, a_out;
////        mapLogic->translateWorldPoint2ScenePoint_noBias(car_positionX_M,car_positionY_M,car_positionA_M
////                                                        ,x_out,y_out, a_out);
////        mapLogic->calculateLaserTransMatrix(x_out,y_out, a_out,tmpMatrixIn);
//        mapLogic->calculateLaserTransMatrix(car_positionX_P,car_positionY_P, (car_positionA_P-90),tmpMatrixIn);
//        laserPointPolygon->setMatrix(tmpMatrixIn);
//    }
//    return 1;

//}

//int MapView::initialCar()
//{

////    std::vector<struct VehiclePosition> carBorderOffsetOut;
////    mapDelegate->getCarBorderOffset(carBorderOffsetOut);
////    mapLogic->setCarBorderAndOffset(carBorderOffsetOut);

//    carBorder = new QGraphicsRectItem(QRectF(0,0,mapLogic->getCarWidth(),mapLogic->getCarHeight()));
//    QPen pen;
//    pen.setWidth(1);
//    pen.setColor(QColor(100,200,50));
//    carBorder->setPen(pen);
//    carBorder->setBrush(QColor(10,200,100));
//    scene->addItem(carBorder);
//    carBorder->setPos(0, 0);

//    QFont tmpFont;
//    tmpFont.setPointSize(18);
//    car_text=scene->addText("A",tmpFont);
//    car_text->setPos(0,0);

//    return 1;
//}

//int MapView::initialLaserPoint()
//{
//    laserPointPolygon = new QGraphicsPolygonItem();
//    QPointF tmpPointF1(0,0);
//    QPointF tmpPointF2(0,100);
//    QPointF tmpPointF3(100,100);
//    QPointF tmpPointF4(-100,-100);
//    QVector<QPointF> tmpPointFVector;
//    tmpPointFVector.append(tmpPointF1);
//    tmpPointFVector.append(tmpPointF2);
//    tmpPointFVector.append(tmpPointF3);
//    tmpPointFVector.append(tmpPointF4);
//    QPolygonF tmpPolygon(tmpPointFVector);
//    laserPointPolygon->setPolygon(tmpPolygon);

//    QPen pen;
//    pen.setWidth(5);
//    pen.setColor(QColor(180,100,50));
//    laserPointPolygon->setPen(pen);
////    laserPointPolygon->setBrush(QColor(10,200,100));
//    scene->addItem(laserPointPolygon);


//    return 1;


//}



int MapView::setVehiclePosition(double x, double y, double a)
{
    car_positionX_M=x;
    car_positionY_M=y;
    car_positionA_M=a;

    mapLogic->translateWorldPoint2ScenePoint(x,y,a,x,y,a);
    car_positionX_P=x;
    car_positionY_P=y;
    car_positionA_P=a;

    return 1;
}

int MapView::setVmarkPosition(double x, double y, double a, bool isDetectedIn)
{
    mapLogic->translateWorldPoint2ScenePoint(x,y,a,x,y,a);
    vmark_positionX_P=x;
    vmark_positionY_P=y;
    vmark_positionA_P=a;
    vmark_isDetected=isDetectedIn;

    return 1;
}

VehiclePosition& MapView::getCurrentSeletPosision()
{
    return currenPosition;
}

void MapView::showMapViewDialog()
{
    if(IF_FOR_AGV_STYLE)
    {
        timer->start(100);
        show();
        g_windowShowManage->addWindow(this,"AGV主窗口");
    }
    else
    {
        qDebug()<<"error, not for agv style";
    }


}

void MapView::showPointsInMap_Slot()
{
    // 释放方向图形内存(重新打开文件时释放)
    scene->freeDPointListItem();

    if(fileData.vehicleDPointList.isEmpty())
    {
        return;
    }

    QVector<int> dpointIndexList;

    std::string currentMapName;
    // 获取当前加载地图文件名
    mapDelegate->getCurrentMapName(currentMapName);
    for(int i=0; i < fileData.vehicleDPointList.size(); i++)
    {
        // 清除地图名中可能存在的空格
        QString tmpMapName = QString::fromStdString(fileData.vehicleDPointList.values().at(i).mapName).remove(QRegExp("\\s*"));
        // 点位所在地图名是否与当前地图名一致
        if(tmpMapName.toStdString() == currentMapName)
        {
            if(fileData.vehicleDPointList.values().at(i).pointType == EM_MOVE_FREE_DP
                    || fileData.vehicleDPointList.values().at(i).pointType == EM_MOVE_FREE_CU1)
            {
                // 记录普通点索引
                dpointIndexList << fileData.vehicleDPointList.keys().at(i);
            }
        }
    }

    double tmp_x,tmp_y,tmp_a;
    for(int i = 0; i < dpointIndexList.size(); i++)
    {
        mapLogic->translateWorldPoint2ScenePoint(fileData.vehicleDPointList.value(dpointIndexList.at(i)).posX/1000,\
                                                 fileData.vehicleDPointList.value(dpointIndexList.at(i)).posY/1000,\
                                                 fileData.vehicleDPointList.value(dpointIndexList.at(i)).posR,\
                                                 tmp_x,tmp_y,tmp_a);

//        qDebug() << "Target_X:" << tmp_x;
//        qDebug() << "Target_Y:" << tmp_y;
//        qDebug() << "Target_R:" << tmp_a;
        scene->drawVehiclePointList(true, tmp_x, tmp_y, tmp_a, fileData.vehicleDPointList[dpointIndexList[i]].dpIndex);
    }
}

void MapView::disableVehicleJog_slot()
{
    qDebug()<<"disableVehicleJog_slot";
    jogFlag=0;
    int returnFlag;
    mapDelegate->manual_stop(returnFlag);//手动停止独立函数，不切换算法工作模式。
}

void MapView::getMapFile_slot()
{
    if(mapDelegate->isControllerConnected())
    {
        fileData.ftpOperateNum = EM_FTP_OPERATE_LOGIN;//单独下载地图文件夹逻辑有问题，需要解决
        ftpManage->getFileInDirectory(D_MAP_PATH,D_MAP_PATH);
    }

}

void MapView::test()
{
    QGraphicsRectItem *item = new QGraphicsRectItem(QRectF(0,0,60,60));
    QPen pen;
    pen.setWidth(3);
    pen.setColor(QColor(qrand()%256,qrand()%256,qrand()%256));
    item->setPen(pen);
    item->setBrush(QColor(qrand()%256,qrand()%256,qrand()%256));
    item->setFlag(QGraphicsItem::ItemIsMovable);
    scene->addItem(item);
    //item->setPos((qrand()%int(scene->sceneRect().width()))-200,(qrand()%int(scene->sceneRect().height()))-200);
    item->setPos(0, 0);
}

void MapView::timeroutslot()
{
    //不能调用gsoap函数，否则因为网络延迟等待，导致界面很卡。
    if(false==mapDelegate->isControllerConnected())
    {
        return;
    }

    VehicleBasicInfo basicInfoReturn;
    mapDelegate->get_vehicle_basic_info(basicInfoReturn);
    showBasicStatus(basicInfoReturn);

    PositionInfo_hmi positionReturn;
    mapDelegate->getVehiclePositionInWorld(positionReturn);
    QStringList occus;
    emit sig_pub_agv_position(0,"hmi",positionReturn.position.x,positionReturn.position.y,
                              positionReturn.position.rotate*180.0/M_PI, occus,basicInfoReturn.currentFloorId);
    updatePositionFeedback(positionReturn);

    showPositionInfo();

    carJogControl();

    if(true==ui->checkBox_isShowLaserData->isChecked())
    {
        std::vector<PointCloudData_3D> pointCloudOut;
        mapDelegate->getAllPointCloud_translated(pointCloudOut);
        scene->drawLaserPoint(pointCloudOut,car_positionX_P,car_positionY_P,car_positionA_P);
    }

    std::string tmpMapName;
    mapDelegate->getCurrentMapName(tmpMapName);
    ui->Label_mapName->setText(QString::fromStdString(tmpMapName));
    checkMap(QString::fromStdString(tmpMapName));

    showVmarkDetectInfo();
    showQrcodeDetectInfo();
    displayAmclDebugInfo();

    ReflectDebugInfo matchDebugInfoOut;
    if(true==mapDelegate->get_isDisplayCalculatedReferenceMarks()
            || true==mapDelegate->get_isDisplayDetectedLaserPoints())
    {
        mapDelegate->getReflectDebugInfo(matchDebugInfoOut);
    }
    if(true==mapDelegate->get_isDisplayCalculatedReferenceMarks())
    {
        scene->displayCalculatedReferenceMarks(matchDebugInfoOut.referenceMarks);
    }
    else
    {
        scene->freeCalculatedReferenceMarks();
    }
    if(true==mapDelegate->get_isDisplayDetectedLaserPoints())
    {
        scene->displayDetectedLaserPoints(matchDebugInfoOut.laserMarks);
    }
    else
    {
        scene->freeDetectedLaserPoints();
    }

    //car border update
    mapLogic->setCarBorderAndOffset(basicInfoReturn.validCarBorder);
    scene->setCarBorderRect(0,0,mapLogic->getCarWidth(),mapLogic->getCarHeight());
    scene->update();

}

void MapView::setShowLandPoint_Slot(bool isShow)
{
    if(false==isShow)
    {
        scene->freeDPointListItem();
    }
    else
    {
        showPointsInMap_Slot();
    }

}

void MapView::setChangeOriginalLaserFilter_slot(int filterIndex)
{
    int returnFlag;
    mapDelegate->setOriginalLaserFilterType(filterIndex,returnFlag);
}

void MapView::setShowReflectDialog_Slot(bool isShow)
{
    if(isShow)
    {
        reflectEditDialog->showDialog();
    }
    else
    {
        reflectEditDialog->hideDialog();
    }

}

void MapView::displayAllReflectMarksInMap_slot(bool isDisplay)
{

    mapDelegate->setDisplayAllReferenceMarks(isDisplay);
    if(isDisplay)
    {
        std::vector<ReflectMarkInfo> reflectMarksOut;
        mapDelegate->getAllReferenceMarks(reflectMarksOut);
        scene->displayAllReferenceMarks(reflectMarksOut);
    }
    else
    {
        scene->freeAllReferenceMarks();
    }

}

void MapView::setShowNormalPositionCircule_slot(bool isShow)
{
    scene->setShowCommonPositionCertainty(isShow);
}

void MapView::setShowReflectPositionCircule_slot(bool isShow)
{
    scene->setShowReflectPositionCertainty(isShow);
}

void MapView::setShowReflectCar_slot(bool isShow)
{
    scene->setShowReflectCar(isShow);
}

void MapView::setShowCommonCar_slot(bool isShow)
{
    scene->setShowCommonCar(isShow);
}

void MapView::updateMatrix()
{
//    QMatrix transFormMatrix(scaleRatio,0 , 0,scaleRatio,xOffset,yOffset);
    QMatrix transFormMatrix;
    transFormMatrix.rotate(rotateAngel);
    transFormMatrix.translate(xOffset,yOffset);
    transFormMatrix.scale(scaleRatio,scaleRatio);
    mapGraphicsView->setMatrix(transFormMatrix);

    qDebug()<<"updateMatrix";
}

void MapView::carJogControl()
{

    if(false==ui->checkBox_jogEnable->isChecked())
    {
        return ;
    }
    jogKeyBoard_stopMonitor();
    jog_button_logic();

    int returnFlag;
    if(true==ui->checkBox->isChecked() && 1==ballJoyStick->getStage())
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(-ballJoyStick->getY()*jogRatio,0,-ballJoyStick->getX()*jogRatio,
                                returnFlag);
    }

    if(2==ballJoyStick->getStage())
    {
       mapDelegate->manual_stop(returnFlag);
       ballJoyStick->setStage(0);
    }

}

int MapView::checkJogCondition()
{
    if(false==ui->checkBox_jogEnable->isChecked())
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("请先点击允许手动复选框"));
        return -1;
    }
    if(1!=mapDelegate->getServoStatus())
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("请先到主页面开启伺服，然后手动"));
        return -1;
    }
    if(0!=mapDelegate->getHandControlType() && 1!=mapDelegate->getHandControlType())
    {
        emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("请先切换到手动T1/T2模式，然后手动"));
        return -1;
    }

    return 1;
}

void MapView::initialShowStyle()
{
    QSettings settings(D_SHOW_STYLE_PATH, QSettings::IniFormat);

    int  width= settings.value("MainWindowDisPlaySize/width").toInt();
    int  heighth= settings.value("MainWindowDisPlaySize/heighth").toInt();
//    setGeometry(680,0,width,heighth);
    setGeometry(680,0,850,heighth);
    setWindowFlags(Qt::FramelessWindowHint);
    //    setAttribute(Qt::WA_TranslucentBackground);
}

void MapView::initialFleetWindow()
{
#ifdef D_USE_FLEET_WINDOW
   mainWindowFleet=new MainWindowFleet(mapDelegate->getDelegate(),
                                      mapDelegate->getGlobalData() ,this);

#endif
}

int MapView::jog_button_logic()
{
    int returnFlag;
    switch(jogFlag)
    {
    case 0:
    {
        return -1;
        break;
    }
    case 1:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(jogRatio,0,0,returnFlag);
        return 1;
        break;
    }
    case 2:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(-jogRatio,0,0,returnFlag);
        return 1;
        break;
    }
    case 3:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(0,jogRatio,0,returnFlag);
        return 1;
        break;
    }
    case 4:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(0,-jogRatio,0,returnFlag);
        return 1;
        break;
    }
    case 5:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(0,0,jogRatio,returnFlag);
        return 1;
        break;
    }
    case 6:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(0,0,-jogRatio,returnFlag);
        return 1;
        break;
    }
    case 7:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(jogRatio,0,jogRatio,returnFlag);
        return 1;
        break;
    }
    case 8:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(jogRatio,0,-jogRatio,returnFlag);
        return 1;
        break;
    }
    case 9:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(-jogRatio,0,-jogRatio,returnFlag);
        return 1;
        break;
    }
    case 10:
    {
        double jogRatio=ui->verticalSlider_speed_jog->value()/100.0;
        mapDelegate->vehicleJog(-jogRatio,0,jogRatio,returnFlag);
        return 1;
        break;
    }
    }
}

int MapView::showVmarkDetectInfo()
{
    if(false==ui->checkBox_isUpdateVmarkDetectInfo->isChecked())
    {
        return -1;
    }

    VisionMatchDebugInfo infoOut;
    mapDelegate->getMatchDebugInfo_vmark(infoOut);//

    model_vmarksDebugInfo->clear();
    //定义item
    QStandardItem* item = 0;

    item = new QStandardItem("成功");
    model_vmarksDebugInfo->setItem(0,0,item);
    item = new QStandardItem(QString::number(infoOut.isMatchSucess));
    model_vmarksDebugInfo->setItem(0,1,item);

    item = new QStandardItem("探得角(度)");
    model_vmarksDebugInfo->setItem(1,0,item);
    item = new QStandardItem(QString::number(infoOut.angleOfLinesOut*180.0/M_PI,'f',3));
    model_vmarksDebugInfo->setItem(1,1,item);

    item = new QStandardItem("合格线段数");
    model_vmarksDebugInfo->setItem(2,0,item);
    item = new QStandardItem(QString::number(infoOut.struct_Line1Count));
    model_vmarksDebugInfo->setItem(2,1,item);

    item = new QStandardItem("当前V槽类号");
    model_vmarksDebugInfo->setItem(3,0,item);
    item = new QStandardItem(QString::number(infoOut.currentVmarkType));
    model_vmarksDebugInfo->setItem(3,1,item);

    item = new QStandardItem("激光过滤号");
    model_vmarksDebugInfo->setItem(4,0,item);
    item = new QStandardItem(QString::number(infoOut.currentLaserFilterType));
    model_vmarksDebugInfo->setItem(4,1,item);


    item = new QStandardItem("最小耗时(ms)");
    model_vmarksDebugInfo->setItem(5,0,item);
    item = new QStandardItem(QString::number(infoOut.minConsumed/1000.0,'f',3));
    model_vmarksDebugInfo->setItem(5,1,item);

    item = new QStandardItem("最大耗时(ms)");
    model_vmarksDebugInfo->setItem(6,0,item);
    item = new QStandardItem(QString::number(infoOut.maxConsumed/1000.0,'f',3));
    model_vmarksDebugInfo->setItem(6,1,item);

    item = new QStandardItem("当前耗时(ms)");
    model_vmarksDebugInfo->setItem(7,0,item);
    item = new QStandardItem(QString::number(infoOut.currentConsumed/1000.0,'f',3));
    model_vmarksDebugInfo->setItem(7,1,item);


    item = new QStandardItem("L1相关系数");
    model_vmarksDebugInfo->setItem(8,0,item);
    item = new QStandardItem(QString::number(infoOut.struct_Line1Corelation,'f',3));
    model_vmarksDebugInfo->setItem(8,1,item);


    item = new QStandardItem("L2相关系数");
    model_vmarksDebugInfo->setItem(9,0,item);
    item = new QStandardItem(QString::number(infoOut.struct_Line2Corelation,'f',3));
    model_vmarksDebugInfo->setItem(9,1,item);

    item = new QStandardItem("探测失败号");
    model_vmarksDebugInfo->setItem(10,0,item);
    item = new QStandardItem(QString::number(infoOut.detectFailedType));
    model_vmarksDebugInfo->setItem(10,1,item);

    item = new QStandardItem("x");
    model_vmarksDebugInfo->setItem(11,0,item);
    item = new QStandardItem(QString::number(infoOut.pos_x,'f',3));
    model_vmarksDebugInfo->setItem(11,1,item);

    item = new QStandardItem("y");
    model_vmarksDebugInfo->setItem(12,0,item);
    item = new QStandardItem(QString::number(infoOut.pos_y,'f',3));
    model_vmarksDebugInfo->setItem(12,1,item);

    item = new QStandardItem("r");
    model_vmarksDebugInfo->setItem(13,0,item);
    item = new QStandardItem(QString::number(infoOut.pos_r*180.0/M_PI,'f',3));
    model_vmarksDebugInfo->setItem(13,1,item);

    item = new QStandardItem("detectedLineCount");
    model_vmarksDebugInfo->setItem(14,0,item);
    item = new QStandardItem(QString::number(infoOut.detectedLineCount));
    model_vmarksDebugInfo->setItem(14,1,item);

    item = new QStandardItem("detectedVmarkCount");
    model_vmarksDebugInfo->setItem(15,0,item);
    item = new QStandardItem(QString::number(infoOut.detectedVmarkCount));
    model_vmarksDebugInfo->setItem(15,1,item);

    item = new QStandardItem("detectedVmarkResultCount");
    model_vmarksDebugInfo->setItem(16,0,item);
    item = new QStandardItem(QString::number(infoOut.detectedVmarkResultCount));
    model_vmarksDebugInfo->setItem(16,1,item);

    item = new QStandardItem("distanceOfLinesOut");
    model_vmarksDebugInfo->setItem(17,0,item);
    item = new QStandardItem(QString::number(infoOut.distanceOfLinesOut,'f',3));
    model_vmarksDebugInfo->setItem(17,1,item);



    ui->tableView_vmarkDebugInfo->setModel(model_vmarksDebugInfo);
    ui->tableView_vmarkDebugInfo->resizeColumnToContents(0);
    ui->tableView_vmarkDebugInfo->resizeColumnToContents(1);
    ui->tableView_vmarkDebugInfo->resizeColumnToContents(2);
    ui->tableView_vmarkDebugInfo->show();
}

int MapView::showQrcodeDetectInfo()
{
    if(false==ui->checkBox_isUpdateQrcodeDebugInfo->isChecked())
    {
        return -1;
    }

    QrcodeDebugInfo infoOut;
    mapDelegate->getQrcodeDebugInfo(infoOut);

    model_qrcodeDebugInfo->clear();
    //定义item
    QStandardItem* item = 0;


    item = new QStandardItem("x(米)");
    model_qrcodeDebugInfo->setItem(0,0,item);
    item = new QStandardItem(QString::number(infoOut.positionFeedback.x,'f',4));
    model_qrcodeDebugInfo->setItem(0,1,item);

    item = new QStandardItem("y(米)");
    model_qrcodeDebugInfo->setItem(1,0,item);
    item = new QStandardItem(QString::number(infoOut.positionFeedback.y,'f',4));
    model_qrcodeDebugInfo->setItem(1,1,item);

    item = new QStandardItem("r(度)");
    model_qrcodeDebugInfo->setItem(2,0,item);
    item = new QStandardItem(QString::number(infoOut.positionFeedback.rotate*180.0/M_PI,'f',3));
    model_qrcodeDebugInfo->setItem(2,1,item);

    item = new QStandardItem("摄像头号");
    model_qrcodeDebugInfo->setItem(3,0,item);
    item = new QStandardItem(QString::number(infoOut.sensorId));
    model_qrcodeDebugInfo->setItem(3,1,item);

    item = new QStandardItem("设备开启");
    model_qrcodeDebugInfo->setItem(4,0,item);
    item = new QStandardItem(QString::number(infoOut.isDeviceOpened));
    model_qrcodeDebugInfo->setItem(4,1,item);


    item = new QStandardItem("图像获取");
    model_qrcodeDebugInfo->setItem(5,0,item);
    item = new QStandardItem(QString::number(infoOut.isImageAcquired));
    model_qrcodeDebugInfo->setItem(5,1,item);


    item = new QStandardItem("方块数");
    model_qrcodeDebugInfo->setItem(6,0,item);
    item = new QStandardItem(QString::number(infoOut.featureSqureCount));
    model_qrcodeDebugInfo->setItem(6,1,item);

    item = new QStandardItem("最小耗时(ms)");
    model_qrcodeDebugInfo->setItem(7,0,item);
    item = new QStandardItem(QString::number(infoOut.minConsumed,'f',3));
    model_qrcodeDebugInfo->setItem(7,1,item);

    item = new QStandardItem("当前耗时(ms)");
    model_qrcodeDebugInfo->setItem(8,0,item);
    item = new QStandardItem(QString::number(infoOut.currentConsumed,'f',3));
    model_qrcodeDebugInfo->setItem(8,1,item);

    item = new QStandardItem("最大耗时(ms)");
    model_qrcodeDebugInfo->setItem(9,0,item);
    item = new QStandardItem(QString::number(infoOut.maxConsumed,'f',3));
    model_qrcodeDebugInfo->setItem(9,1,item);

    ui->tableView_qrcodeDebugInfo->setModel(model_qrcodeDebugInfo);
    ui->tableView_qrcodeDebugInfo->resizeColumnToContents(0);
    ui->tableView_qrcodeDebugInfo->resizeColumnToContents(1);
    ui->tableView_qrcodeDebugInfo->resizeColumnToContents(2);
    ui->tableView_qrcodeDebugInfo->show();
}

int MapView::displayAmclDebugInfo()
{
    if(false==ui->checkBox_isUpdateAmclDebugInfo->isChecked())
    {
        return -1;
    }

    AmclDebugInfo infoOut;
    mapDelegate->getAmclDebugInfo( infoOut);

    model_amclDebugInfo->clear();
    //定义item
    QStandardItem* item = 0;


    item = new QStandardItem("位置修正");
    model_amclDebugInfo->setItem(0,0,item);
    item = new QStandardItem(QString::number(infoOut.isCorrectSucess));
    model_amclDebugInfo->setItem(0,1,item);

    item = new QStandardItem("修正计数");
    model_amclDebugInfo->setItem(1,0,item);
    item = new QStandardItem(QString::number(infoOut.correctCount));
    model_amclDebugInfo->setItem(1,1,item);

    item = new QStandardItem("修正x(m)");
    model_amclDebugInfo->setItem(2,0,item);
    item = new QStandardItem(QString::number(infoOut.correctPositionOffset.x,'f',3));
    model_amclDebugInfo->setItem(2,1,item);

    item = new QStandardItem("修正y(m)");
    model_amclDebugInfo->setItem(3,0,item);
    item = new QStandardItem(QString::number(infoOut.correctPositionOffset.y,'f',3));
    model_amclDebugInfo->setItem(3,1,item);

    item = new QStandardItem("修正r(degree)");
    model_amclDebugInfo->setItem(4,0,item);
    item = new QStandardItem(QString::number(infoOut.correctPositionOffset.rotate*180.0/M_PI,'f',3));
    model_amclDebugInfo->setItem(4,1,item);



    ui->tableView_amclDebugInfo->setModel(model_amclDebugInfo);
    ui->tableView_amclDebugInfo->resizeColumnToContents(0);
    ui->tableView_amclDebugInfo->resizeColumnToContents(1);
    ui->tableView_amclDebugInfo->resizeColumnToContents(2);
    ui->tableView_amclDebugInfo->show();
}




void MapView::on_pushButton_zoomIn_clicked()
{

    scaleRatio+=0.2;

    updateMatrix();
    qDebug()<<"zoomIn scaleRatio="<<scaleRatio;
}

void MapView::on_pushButton_zoomOut_clicked()
{
    if(scaleRatio-0.2>0.05)
    {
        scaleRatio-=0.2;
    }
    updateMatrix();
    qDebug()<<"zoomOut scaleRatio="<<scaleRatio;
}






void MapView::on_checkBox_clicked(bool checked)
{
    if(checked)
    {
        ballJoyStick->move(50,100);
        ballJoyStick->show();
    }
    else{
        ballJoyStick->hide();
    }
}


void MapView::on_checkBox_3_clicked(bool checked)
{
    if(checked)
    {
//        mapEditToolBox->move(100,200);

//        ui->dockWidget_tool->resize(180,300);
//        ui->dockWidget_tool->show();
//        mapEditToolBox->show();
        ui->toolBox_container->show();
    }
    else
    {
//        ui->dockWidget_tool->hide();
//        mapEditToolBox->hide();
        ui->toolBox_container->hide();
    }
}

void MapView::on_pushButton_setPosition_clicked()
{
    QMessageBox message(QMessageBox::Question, "提示", "是否开始重定位！"
                        , QMessageBox::Yes|QMessageBox::No , NULL);
    if(message.exec() == QMessageBox::No)
    {
        return;
    }
    VehiclePosition positionIn;
    scene->getWorldPosition(positionIn.x,positionIn.y,positionIn.rotate);
    int tmpReturn;
    mapDelegate->setVehiclePosition(positionIn,tmpReturn);
}

void MapView::on_pushButton_moveToPosition_clicked()
{
    if(0==ui->comboBox_moveToPathType->currentIndex())
    {
        QMessageBox message(QMessageBox::Question, "提示", "请先在下拉框选择路径类型！"
                            , QMessageBox::Ok , NULL);
        message.exec();
        return ;

    }
    if(1<mapDelegate->getHandControlType())
    {
        QMessageBox message(QMessageBox::Question, "提示", "请先切换到手动模式！"
                            , QMessageBox::Ok , NULL);
        message.exec();
        return ;

    }


    QMessageBox message(QMessageBox::Question, "提示", "是否开始运动！"
                        , QMessageBox::Yes|QMessageBox::No , NULL);
    if(message.exec() == QMessageBox::No)
    {
        return;
    }
    VehiclePosition positionIn;
    scene->getWorldPosition(positionIn.x,positionIn.y,positionIn.rotate);
    int tmpReturn;
    MovingToNavagationParameter parameterIn;

    parameterIn.x=1000.0*positionIn.x;//mm
    parameterIn.y=1000.0*positionIn.y;//mm
    parameterIn.rotate=180.0*positionIn.rotate/M_PI;//unit is degree
    parameterIn.speedRatio=1;//0-1之间。主界面的速度滑动条可以调节运行中的速度。
    parameterIn.isPositiveDirection=true; //正向、反向运行。华磊
    parameterIn.vmarkTypeNum=0;//VMARK　或 QRCODE 参照索引号
    parameterIn.laserTypeNum=0;//激光区域号码
    parameterIn.isDetectBarrier=true;
    parameterIn.barrierRunMode=0;//探测方法
    parameterIn.pointSensorType=EM_MOVE_FREE_DP;//globaldefine.h MOVE_FREE_POINT_TYPE定义 ,E_MOVE_FREE_POINTS_MODE(作废）
    parameterIn.moveFreeMode=E_MOVE_FREE_IMU;                 // 自由导航模式 wheel imu laser
    parameterIn.CNT_Value=0;
    parameterIn.allowAccuracy=0.25;//停车精度，单位米
    parameterIn.pathControlStrategy=E_PATH_CONTROL_STRATEGY_DIFFERENTIAL;

    switch(ui->comboBox_moveToPathType->currentIndex())
    {
    case 1:
    {
        parameterIn.moveFreeMoveTrajectoryType=E_NAV_COMMAND_LINE;
        break;
    }
    case 2:
    {
        parameterIn.moveFreeMoveTrajectoryType=E_NAV_COMMAND_SPLINE;
        break;
    }
    case 3:
    {
        parameterIn.moveFreeMoveTrajectoryType=E_NAV_COMMAND_ROTATE;
        break;
    }
    default:
    {
        QMessageBox message2(QMessageBox::Question, "提示", "不支持的路径类型！", QMessageBox::Ok , NULL);
        message2.exec();
        return ;
    }
    }



    mapDelegate->moveToNavgationPoint(parameterIn,tmpReturn);
    //    mapDelegate->moveToPosition(positionIn,ui->verticalSlider_speed->value()/100, tmpReturn);


}



void MapView::on_pushButton_mapHide_clicked()
{
    timer->stop();
    hide();
}

//void MapView::on_pushButton_loadMap_2_clicked()
//{
//    int returnFlag;
//    QString filePath =ui->lineEdit_mapPath->text();
//    int first = filePath.lastIndexOf ("/"); //从后面查找"/"位置
//    QString title = filePath.right (filePath.length ()-first-1); //从右边截取
//    qDebug()<<title;
////    reloadMap(filePath);
////    int returnFlag;
////    currentShowMapName=title;//设置默认地图后，无法更新同步显示新的地图
//    mapDelegate->loadMap(title.toStdString(),returnFlag);
//}

//void MapView::on_pushButton_browseFile_clicked()
//{
//    //定义文件对话框类
//       QFileDialog *fileDialog = new QFileDialog(this);
//       fileDialog->resize(400,500);
//       //定义文件对话框标题
//       fileDialog->setWindowTitle(tr("选择文件"));
//       //设置默认文件路径
//       fileDialog->setDirectory(D_MAP_PATH);
//       //设置文件过滤器
//       fileDialog->setNameFilter(tr("yaml(*.yaml)"));
//       //设置可以选择多个文件,默认为只能选择一个文件QFileDialog::ExistingFiles
//       fileDialog->setFileMode(QFileDialog::ExistingFiles);
//       //设置视图模式
//       fileDialog->setViewMode(QFileDialog::Detail);
//       //打印所有选择的文件的路径
//       QStringList fileNames;
//       if(fileDialog->exec())
//       {
//           fileNames = fileDialog->selectedFiles();
//       }
//        qDebug()<<fileNames;
//        if(fileNames.size()>0)
//        {
//            ui->lineEdit_mapPath->setText(fileNames[0]);
//        }
//}

//void MapView::on_pushButton_createMapStart_clicked()
//{
//    int returnFlag;
//    mapDelegate->createMapStart(returnFlag);
//}

//void MapView::on_pushButton_createMapStop_clicked()
//{
//    int returnFlag;
//    QString tmpFilePath;
//    tmpFilePath+=ui->lineEdit_mapName_2->text();

//    mapDelegate->createMapEnd(tmpFilePath.toStdString(),  returnFlag);
//}

void MapView::on_pushButton_setMapSolver_clicked()
{
    int returnFlag;
    mapDelegate->setMapSolver((E_MAP_SOLVER)ui->comboBox_mapSolver->currentIndex(),1, returnFlag);
    QMessageBox::information(NULL,"设置地图算法成功","设置地图算法成功",tr("ＯＫ"));
}

void MapView::on_pushButton_setOdomSolver_clicked()
{
    int returnFlag;
    mapDelegate->setOdomSolver((E_ODOM_SOLVER)ui->lineEdit_odometer->text().toInt(), returnFlag);
}

void MapView::on_pushButton_setLocationSolver_clicked()
{
    int returnFlag;
    mapDelegate->setLocationSolver((E_LOCATION_SOLVER)ui->lineEdit_locationSolver->text().toInt(), returnFlag);
}

void MapView::on_pushButton_getVehiclePosition_clicked()
{
    PositionInfo_hmi positionReturn;
    mapDelegate->getVehiclePositionInWorld(positionReturn);
    ui->lineEdit_rx->setText(QString::number(positionReturn.position.x));
    ui->lineEdit_ry->setText(QString::number(positionReturn.position.y));
    ui->lineEdit_ra->setText(QString::number(positionReturn.position.rotate/M_PI*180));
}

//void MapView::on_pushButton_setVehiclePosition_clicked()
//{
//    int returnFlag;
//    VehiclePosition positionIn;
//    positionIn.x=ui->lineEdit_ix->text().toDouble();
//    positionIn.y=ui->lineEdit_iy->text().toDouble();
//    positionIn.rotate=ui->lineEdit_ia->text().toDouble();
//    mapDelegate->setVehiclePosition(positionIn, returnFlag);

//}

void MapView::on_pushButton_setTrajectoryGlobalPlanSolver_clicked()
{
    int returnFlag;
    mapDelegate->setTrajectoryGlobalPlanSolver((E_TRAJECTORY_GLOBAL_SOLVER)ui->lineEdit_globalPlan->text().toInt(), returnFlag);
}

void MapView::on_pushButton_setTrajectoryLocalPlanSolver_clicked()
{
    int returnFlag;
    mapDelegate->setTrajectoryLocalPlanSolver((E_TRAJECTORY_LOCAL_SOLVER)ui->lineEdit_localPlan->text().toInt(), returnFlag);
}

//void MapView::on_pushButton_moveToPosition_2_clicked()
//{
//    int returnFlag;
//    VehiclePosition positionIn;
//    positionIn.x=ui->lineEdit_tx->text().toDouble();
//    positionIn.y=ui->lineEdit_ty->text().toDouble();
//    positionIn.rotate=ui->lineEdit_ta->text().toDouble();
//    mapDelegate->moveToPosition(positionIn, ui->lineEdit_velocity->text().toDouble(),returnFlag);
//}

void MapView::on_pushButton_changeVelocity_clicked()
{
    int returnFlag;
    mapDelegate->changeVelocity(ui->lineEdit_velocity->text().toDouble(),returnFlag);
}

void MapView::on_pushButton_start_clicked()
{
    int returnFlag;

    mapDelegate->startMotion(returnFlag);
}

void MapView::on_pushButton_cease_clicked()
{
    int returnFlag;

    mapDelegate->ceaseMotion(returnFlag);
}

void MapView::on_pushButton_stop_clicked()
{
    int returnFlag;

    mapDelegate->cancelMotion(returnFlag);
}

void MapView::on_recodMapDPoint_Btn_clicked()
{
    // 获取在地图界面选中的点位数据
    scene->getWorldPosition(currenPosition.x,currenPosition.y,currenPosition.rotate);
    currenPosition.rotate = currenPosition.rotate/M_PI*180;
    emit reordMapPointSignal(D_RECORD_MAP_SELECTI_POINT);
}

void MapView::on_pushButton_front_trans_pressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=1;

}

void MapView::on_pushButton_back_trans_pressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=2;

}

void MapView::on_pushButton_left_trans_pressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=3;
}

void MapView::on_pushButton_right_trans_pressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=4;
}

void MapView::on_pushButton_left_rotation_pressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=5;

}

void MapView::on_pushButton_right_rotation_pressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=6;
}

void MapView::jogFrontLeftPressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=7;
}

void MapView::jogFrontRightPressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=8;
}

void MapView::jogBackLeftPressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=9;
}

void MapView::jogBackRightPressed()
{
    if(1!=checkJogCondition())
    {
        return ;
    }
    jogFlag=10;
}

void MapView::on_pushButton_front_trans_released()
{
    jogFlag=0;
    int returnFlag;
    mapDelegate->manual_stop(returnFlag);

}

void MapView::on_pushButton_back_trans_released()
{
    //为什么按下去emit信号后，这个不响应了。
    jogFlag=0;
    int returnFlag;
    mapDelegate->manual_stop(returnFlag);
}

void MapView::on_pushButton_left_trans_released()
{
    jogFlag=0;
    int returnFlag;
    mapDelegate->manual_stop(returnFlag);
}

void MapView::on_pushButton_right_trans_released()
{
    jogFlag=0;
    int returnFlag;
    mapDelegate->manual_stop(returnFlag);
}

void MapView::on_pushButton_left_rotation_released()
{
    jogFlag=0;
    int returnFlag;
    mapDelegate->manual_stop(returnFlag);
}

void MapView::on_pushButton_right_rotation_released()
{
    jogFlag=0;
    int returnFlag;
    mapDelegate->manual_stop(returnFlag);
}

void MapView::on_pushButton_reset_vehicle_short_odom_clicked()
{
    int returnFlag;
    mapDelegate->clear_odomter(returnFlag);
}



void MapView::on_pushButton_update_map_list_clicked()
{
    ui->listWidget_mapList_remote->clear();
    std::vector<std::string> fileList;
    mapDelegate->get_map_list(fileList);
    for(int i=0;i<fileList.size();i++)
    {
        ui->listWidget_mapList_remote->addItem(QString::fromStdString(fileList[i]));
    }
}

void MapView::on_pushButton_loadMap_clicked()
{
    QMessageBox message(QMessageBox::Question, "提示", "是否加载选定的地图？（加载后必须重新手动设定agv初始位置！）！"
                        , QMessageBox::Yes|QMessageBox::No , NULL);
    if(message.exec() == QMessageBox::No)
    {
        return;
    }

    int returnFlag;
//    QString filePath;//todo 通过ｆｔｐ去更新地图文件
    if(NULL!=ui->listWidget_mapList_remote->currentItem())
    {
        QString title = ui->listWidget_mapList_remote->currentItem()->text();
        qDebug()<<title;
    //    reloadMap(filePath);//checkmap函数会定时执行，如果地图变了，他会加载
    //    int returnFlag;
        mapDelegate->loadMap(title.toStdString(),returnFlag);
    }
    QString tmpInfo;
    switch (returnFlag) {

    case 1:
        tmpInfo="切换地图成功，请手动设定agv初始位置，否则agv定位错误！!";
        break;
    default:
        tmpInfo="加载地图失败!";
        qDebug()<<"加载地图失败!"<<returnFlag;
        break;
    }
    QMessageBox::information(NULL,"提示",tmpInfo,tr("ＯＫ"));
}

void MapView::on_pushButton_createMapStart_2_clicked()
{
    int returnFlag;
    mapDelegate->createMapStart(returnFlag);
    QString tmpInfo;
    switch (returnFlag) {
    case -1:
        tmpInfo="创建地图开始失败,请先切换到手动模式!";
        break;
    case -2:
        tmpInfo="失败,不支持的创建地图算法!";
        break;
    case 1:
        tmpInfo="创建地图开始,请手动AGV巡航工作区域.输入地图名称,再点击创建地图结束!";
        break;
    default:
        break;
    }
    QMessageBox::information(NULL,"提示",tmpInfo,tr("ＯＫ"));
}

void MapView::on_pushButton_endMap_and_save_clicked()
{
    int returnFlag;
    QString tmpFilePath;
    tmpFilePath=ui->lineEdit_mapSaveName->text();

    mapDelegate->createMapEnd(tmpFilePath.toStdString(),  returnFlag);
    QString tmpInfo;
    switch (returnFlag) {
    case -1:
        tmpInfo="保存地图失败,请切换手动模式!";
        break;
    case -2:
        tmpInfo="保存地图失败,请输入地图名称!";
        break;
    case -3:
        tmpInfo="保存地图失败,不支持的地图方法!";
        break;
    case -4:
        tmpInfo="保存地图失败,错误4!";
        break;
    case -5:
        tmpInfo="保存地图失败,错误5!";
        break;
    case -200:
        tmpInfo="保存地图失败,请先点击创建地图开始!";
        break;
    case 1:
        tmpInfo="创建地图结束,5秒后点击获取地图列表,查看并加载新地图!";
        break;
    default:
        break;
    }
    QMessageBox::information(NULL,"提示",tmpInfo,tr("ＯＫ"));
}

int MapView::updatePositionFeedback(PositionInfo_hmi positionReturn)
{ 

    setVehiclePosition(positionReturn.position.x ,positionReturn.position.y,
                       positionReturn.position.rotate/M_PI*180.0);

    // 定时器调用,更新显示小车位置
    scene->drawCommonCar(car_positionX_P,car_positionY_P,car_positionA_P);
    scene->drawCommonPositionCertainty(positionReturn.position.x ,positionReturn.position.y,
                                       mapLogic->translateToSceneLength(positionReturn.maxMatchError));
    PositionInfo_hmi positionCu1;
    mapDelegate->getVehiclePositionInCU1(positionCu1);
    double cu1_x,cu1_y,cu1_a;
    mapLogic->translateWorldPoint2ScenePoint(positionCu1.position.x,positionCu1.position.y,
                                             positionCu1.position.rotate/M_PI*180.0,cu1_x,cu1_y,cu1_a);
    scene->drawReflectCar(cu1_x,cu1_y,cu1_a);
    scene->drawReflectPositionCertainty(positionCu1.position.x ,positionCu1.position.y,
                                       mapLogic->translateToSceneLength(positionCu1.maxMatchError));


    double tmpX,tmpY,tmpA;
    scene->getWorldPosition(tmpX,tmpY,tmpA);
    double tmpLength=scene->getWorldLength();
    ui->label_xValue_map->setText(QString::number(tmpX,'f',3));
    ui->label_yValue_map->setText(QString::number(tmpY,'f',3));
    ui->label_aValue_map->setText(QString::number(tmpA/M_PI*180,'f',3));
    ui->label_userPointLength->setText(QString::number(tmpLength,'f',3));
    ui->label_vehiclePosition_matchScore->setText(QString::number(positionReturn.matchScore,'f',1));


    ui->label_xValue->setText(QString::number(positionReturn.position.x,'f',3));
    ui->label_yValue->setText(QString::number(positionReturn.position.y,'f',3));
    ui->label_aValue->setText(QString::number(positionReturn.position.rotate/M_PI*180,'f',3));

    //position amcl 显示
    ui->textEdit_vehiclePos_amcl->clear();
    QString tmpLineStr;
    if(true==positionReturn.isUpdateSucess)
    {
        ui->textEdit_vehiclePos_amcl->append("成功");
    }
    else
    {
        ui->textEdit_vehiclePos_amcl->append("失败");
    }
    tmpLineStr="x=";
    tmpLineStr+=QString::number(positionReturn.position.x,10,3);
    ui->textEdit_vehiclePos_amcl->append(tmpLineStr);
    tmpLineStr="y=";
    tmpLineStr+=QString::number(positionReturn.position.y,10,3);
    ui->textEdit_vehiclePos_amcl->append(tmpLineStr);
    tmpLineStr="r=";
    tmpLineStr+=QString::number(positionReturn.position.rotate*180.0/M_PI,10,3);
    ui->textEdit_vehiclePos_amcl->append(tmpLineStr);
    tmpLineStr="score=";
    tmpLineStr+=QString::number(positionReturn.matchScore,10,3);
    ui->textEdit_vehiclePos_amcl->append(tmpLineStr);
    tmpLineStr="error=";
    tmpLineStr+=QString::number(positionReturn.maxMatchError,10,3);
    ui->textEdit_vehiclePos_amcl->append(tmpLineStr);

    //vmark in world
    PositionInfo_hmi vmark_positionReturn;
    mapDelegate->getVMarkPositionInWorld(vmark_positionReturn);
    setVmarkPosition(vmark_positionReturn.position.x ,vmark_positionReturn.position.y,vmark_positionReturn.position.rotate/M_PI*180.0,
                     vmark_positionReturn.isUpdateSucess);
    if(true==vmark_positionReturn.isUpdateSucess)
    {
        ui->lineEdit_vmarkInWorldIsScuess->setText("成功");
        ui->lineEdit_vmark_in_world_x->setText(QString::number(vmark_positionReturn.position.x,'f',3));
        ui->lineEdit_vmark_in_world_y->setText(QString::number(vmark_positionReturn.position.y,'f',3));
        ui->lineEdit_vmark_in_world_r->setText(QString::number(vmark_positionReturn.position.rotate/M_PI*180,'f',3));
        scene->drawVmark(true,vmark_positionX_P,vmark_positionY_P,vmark_positionA_P);
    }
    else
    {
        ui->lineEdit_vmarkInWorldIsScuess->setText("失败");
        scene->drawVmark(false,0,0,0);
    }

    //baselink in vmark
    mapDelegate->getVehiclePositionInVmark(vmark_positionReturn);
    if(true==vmark_positionReturn.isUpdateSucess)
    {
        ui->lineEdit_baselink_in_vmark_is_sucess->setText("成功");
        ui->lineEdit_baselink_in_vmark_x->setText(QString::number(vmark_positionReturn.position.x,'f',3));
        ui->lineEdit_baselink_in_vmark_y->setText(QString::number(vmark_positionReturn.position.y,'f',3));
        ui->lineEdit_baselink_in_vmark_r->setText(QString::number(vmark_positionReturn.position.rotate/M_PI*180,'f',3));
    }
    else
    {
        ui->lineEdit_baselink_in_vmark_is_sucess->setText("失败");
    }


    return 1;
}

int MapView::showBasicStatus(VehicleBasicInfo &basicInfoIn)
{
    switch(basicInfoIn.fleetBasicStatus)
    {
    case E_AGV_STATE_IDILE:
    {
        ui->lineEdit_basicStatus->setText("空闲");
        break;
    }
    case E_AGV_STATE_MOVING:
    {
        ui->lineEdit_basicStatus->setText("运行中");
        break;
    }
    case E_AGV_STATE_LOSE_POSITION:
    {
        ui->lineEdit_basicStatus->setText("丢失位置");
        break;
    }
    case E_AGV_STATE_LASER_CEASE:
    {
        ui->lineEdit_basicStatus->setText("激光壁障");
        break;
    }
    case E_AGV_STATE_LASER_STOP:
    {
        ui->lineEdit_basicStatus->setText("激光停止");
        break;
    }
    case E_AGV_STATE_INFRARED_STOP:
    {
        ui->lineEdit_basicStatus->setText("红外停止");
        break;
    }
    case E_AGV_STATE_ULTRASONIC_STOP:
    {
        ui->lineEdit_basicStatus->setText("超声波停止");
        break;
    }
    case E_AGV_STATE_CHARGING:
    {
        ui->lineEdit_basicStatus->setText("充电");
        break;
    }
    case E_AGV_STATE_CEASE:
    {
        ui->lineEdit_basicStatus->setText("暂停");
        break;
    }
    case E_AGV_STATE_EMERGENCE_STOP:
    {
        ui->lineEdit_basicStatus->setText("急停");
        break;
    }
    case E_AGV_STATE_ULTRASONIC_CEASE:
    {
        ui->lineEdit_basicStatus->setText("超声波壁障");
        break;
    }
    case E_AGV_STATE_INTERNAL_ERROR:
    {
        ui->lineEdit_basicStatus->setText("内部错误");
        break;
    }
    case E_AGV_STATE_COMMAND_READY:
    {
        ui->lineEdit_basicStatus->setText("命令待启动");
        break;
    }
    default:
    {
         ui->lineEdit_basicStatus->setText("未知状态");
    }
    }
    ui->lineEdit_passedStation->setText(QString::number(basicInfoIn.pathMoveingInfo.passedStationId));
    ui->lineEdit_currentStation->setText(QString::number(basicInfoIn.pathMoveingInfo.currentStationId));
    ui->lineEdit_nextStation->setText(QString::number(basicInfoIn.pathMoveingInfo.nextStationId));
    ui->lineEdit_passedPath->setText(QString::number(basicInfoIn.pathMoveingInfo.passedPathId));
    ui->lineEdit_currentPath->setText(QString::number(basicInfoIn.pathMoveingInfo.currentPathId));
    ui->lineEdit_nextPath->setText(QString::number(basicInfoIn.pathMoveingInfo.nextPathId));
    ui->label_currentMapVersion->setText(QString::number(basicInfoIn.mapVersion));
//    QString tmpString="剩余距离：";
    ui->TargetLeftInfo_Distance_Value->setText(QString::number(basicInfoIn.absoluteDistanceLeft,'f',3));
//    tmpString+=" 　剩余角度：";
    ui->Transposition_Value->setText(QString::number(180.0*basicInfoIn.absoluteAngleLeft/M_PI,'f',2));
//    ui->label_targetLeftInfo->setText(tmpString);
    if(E_VEHICLE_POSITION_TYPE_ROS==basicInfoIn.usingPositionType)
    {
        ui->label_currentPositionType->setText("通用定位");
    }
    else if(E_VEHICLE_POSITION_TYPE_VMARK==basicInfoIn.usingPositionType)
    {
        ui->label_currentPositionType->setText("V槽定位");
    }
    else if(E_VEHICLE_POSITION_TYPE_QRCODE==basicInfoIn.usingPositionType)
    {
        ui->label_currentPositionType->setText("二维码定位");
    }
    else if(E_VEHICLE_POSITION_TYPE_CU1==basicInfoIn.usingPositionType)
    {
        ui->label_currentPositionType->setText("反光定位");
    }
    else
    {
        ui->label_currentPositionType->setText(QString::number(basicInfoIn.usingPositionType)+"未知");
    }

    if(E_BARRIER_RUN_MODE_NONE==basicInfoIn.barrierMethod)
    {
        ui->label_barrierMethod->setText("不探测");
    }
    else if(E_BARRIER_RUN_MODE_COMMON==basicInfoIn.barrierMethod)
    {
        ui->label_barrierMethod->setText("普通");
    }
    else if(E_BARRIER_RUN_MODE_VMARK==basicInfoIn.barrierMethod)
    {
        ui->label_barrierMethod->setText("窄通道");
    }
    else if(E_BARRIER_RUN_MODE_NARROW_A==basicInfoIn.barrierMethod)
    {
        ui->label_barrierMethod->setText("超窄A");
    }
    else if(E_BARRIER_RUN_MODE_NARROW_B==basicInfoIn.barrierMethod)
    {
        ui->label_barrierMethod->setText("超窄B");
    }
    else
    {
        ui->label_barrierMethod->setText(QString::number(basicInfoIn.barrierMethod));
    }

    if(0==basicInfoIn.currentBorderId)
    {
        ui->label_currentBorderId->setText("原始车框");
    }
    else if(1==basicInfoIn.currentBorderId)
    {
        ui->label_currentBorderId->setText("货架A");
    }
    else if(2==basicInfoIn.currentBorderId)
    {
        ui->label_currentBorderId->setText("货架B");
    }
    else
    {
        ui->label_currentBorderId->setText(QString::number(basicInfoIn.currentBorderId));
    }



    showCurrentPath(basicInfoIn.startPosition,basicInfoIn.targetPosition,(E_NAV_COMMAND)basicInfoIn.currentPathType,
                    basicInfoIn.currentPathParameter1,basicInfoIn.currentPathParameter2);

    // 目标点位
    if(basicInfoIn.targetPosition.size()>0)
    {
        showTargetPoint(basicInfoIn.targetPosition.back());
        ui->TargetPoint_X_Value->setText(QString::number(basicInfoIn.targetPosition.back().x,'f',2));
        ui->TargetPoint_Y_Value->setText(QString::number(basicInfoIn.targetPosition.back().y,'f',2));
        ui->TargetPoint_R_Value->setText(QString::number(180.0*basicInfoIn.targetPosition.back().rotate/M_PI,'f',2));
    }

    QString tmpStrBattery=QString::number((int)(basicInfoIn.batteryLightModeLeft*100));
    tmpStrBattery+="%";
    ui->label_batteryLightmode_left->setText(tmpStrBattery);
    ui->lineEdit_vehicle_odom_long->setText(QString::number(basicInfoIn.odometer_history,'f',0));
    ui->label_odom_history->setText(QString::number(basicInfoIn.odometer_history,'f',0));
    ui->lineEdit_vehicle_odom_short->setText(QString::number(basicInfoIn.odometer_user,'f',0));
    ui->lineEdit_vehicle_odom_time_long->setText(QString::number(basicInfoIn.time_history,'f',0));
    ui->lineEdit_vehicle_odom_time_short->setText(QString::number(basicInfoIn.time_user,'f',0));
    ui->label_speedFeedback_vehicle->setText(QString::number(basicInfoIn.vehicleVelocityFeedback.x_move,'f',3));
    ui->label_speed_rotation_feedback_vehicle->setText(QString::number(
                               180.0*basicInfoIn.vehicleVelocityFeedback.z_rotate/M_PI,'f',2));

    //超声波距离显示
    ui->textEdit_ultrasonicDistance->clear();
    QString tmpLineStr;
    for(int i=0;i<basicInfoIn.ultrasonicDistance.size();i++)
    {
        tmpLineStr=QString::fromStdString(basicInfoIn.ultrasonicSensorName[i])+" ,";
        tmpLineStr+=QString::number(basicInfoIn.ultrasonicDistance[i],10,0);
        ui->textEdit_ultrasonicDistance->append(tmpLineStr);
    }

    if(basicInfoIn.ultrasonicSafeStatus.size()>=4)
    {
        ui->lineEdit_ultrasonic_safeRatio_1->
                setText(QString::number(basicInfoIn.ultrasonicSafeStatus[0],'f',2));
        ui->lineEdit_ultrasonic_safeRatio_2->
                setText(QString::number(basicInfoIn.ultrasonicSafeStatus[1],'f',2));
        ui->lineEdit_ultrasonic_safeRatio_3->
                setText(QString::number(basicInfoIn.ultrasonicSafeStatus[2],'f',2));
        ui->lineEdit_ultrasonic_safeRatio_4->
                setText(QString::number(basicInfoIn.ultrasonicSafeStatus[3],'f',2));

        if(0.9<=basicInfoIn.ultrasonicSafeStatus[0])
        {
           ui->lineEdit_ultrasonic_safeRatio_1->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.ultrasonicSafeStatus[0])
        {
           ui->lineEdit_ultrasonic_safeRatio_1->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_ultrasonic_safeRatio_1->setStyleSheet("background-color: rgb(231, 0, 0);");
        }

        if(0.9<=basicInfoIn.ultrasonicSafeStatus[1])
        {
           ui->lineEdit_ultrasonic_safeRatio_2->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.ultrasonicSafeStatus[1])
        {
           ui->lineEdit_ultrasonic_safeRatio_2->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_ultrasonic_safeRatio_2->setStyleSheet("background-color: rgb(231, 0, 0);");
        }

        if(0.9<=basicInfoIn.ultrasonicSafeStatus[2])
        {
           ui->lineEdit_ultrasonic_safeRatio_3->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.ultrasonicSafeStatus[2])
        {
           ui->lineEdit_ultrasonic_safeRatio_3->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_ultrasonic_safeRatio_3->setStyleSheet("background-color: rgb(231, 0, 0);");
        }

        if(0.9<=basicInfoIn.ultrasonicSafeStatus[3])
        {
           ui->lineEdit_ultrasonic_safeRatio_4->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.ultrasonicSafeStatus[3])
        {
           ui->lineEdit_ultrasonic_safeRatio_4->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_ultrasonic_safeRatio_4->setStyleSheet("background-color: rgb(231, 0, 0);");
        }
    }
//    ui->lineEdit_ultrasonic_safe_check_allow->setText(QString::number(basicInfoReturn.ultrasonicCheckEnable));

    if(basicInfoIn.pointSensorName.size()>=4)
    {
        ui->label_pointCloudName1->setText(QString::fromStdString(basicInfoIn.pointSensorName[0]));
        ui->label_pointCloudName2->setText(QString::fromStdString(basicInfoIn.pointSensorName[1]));
        ui->label_pointCloudName3->setText(QString::fromStdString(basicInfoIn.pointSensorName[2]));
        ui->label_pointCloudName4->setText(QString::fromStdString(basicInfoIn.pointSensorName[3]));

    }
    if(basicInfoIn.pointSensorSafeRatio.size()>=4)
    {
        ui->lineEdit_pointCloud_safeRatio1->
                setText(QString::number(basicInfoIn.pointSensorSafeRatio[0],'f',2));
        ui->lineEdit_pointCloud_safeRatio2->
                setText(QString::number(basicInfoIn.pointSensorSafeRatio[1],'f',2));
        ui->lineEdit_pointCloud_safeRatio3->
                setText(QString::number(basicInfoIn.pointSensorSafeRatio[2],'f',2));
        ui->lineEdit_pointCloud_safeRatio4->
                setText(QString::number(basicInfoIn.pointSensorSafeRatio[3],'f',2));

        if(0.9<=basicInfoIn.pointSensorSafeRatio[0])
        {
           ui->lineEdit_pointCloud_safeRatio1->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.pointSensorSafeRatio[0])
        {
           ui->lineEdit_pointCloud_safeRatio1->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_pointCloud_safeRatio1->setStyleSheet("background-color: rgb(231, 0, 0);");
        }

        if(0.9<=basicInfoIn.pointSensorSafeRatio[0])
        {
           ui->lineEdit_pointCloud_safeRatio1->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.pointSensorSafeRatio[0])
        {
           ui->lineEdit_pointCloud_safeRatio1->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_pointCloud_safeRatio1->setStyleSheet("background-color: rgb(231, 0, 0);");
        }

        if(0.9<=basicInfoIn.pointSensorSafeRatio[1])
        {
           ui->lineEdit_pointCloud_safeRatio2->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.pointSensorSafeRatio[1])
        {
           ui->lineEdit_pointCloud_safeRatio2->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_pointCloud_safeRatio2->setStyleSheet("background-color: rgb(231, 0, 0);");
        }

        if(0.9<=basicInfoIn.pointSensorSafeRatio[2])
        {
           ui->lineEdit_pointCloud_safeRatio3->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.pointSensorSafeRatio[2])
        {
           ui->lineEdit_pointCloud_safeRatio3->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_pointCloud_safeRatio3->setStyleSheet("background-color: rgb(231, 0, 0);");
        }

        if(0.9<=basicInfoIn.pointSensorSafeRatio[3])
        {
           ui->lineEdit_pointCloud_safeRatio4->setStyleSheet("background-color: rgb(0, 231, 0);");
        }
        else if(0.01<=basicInfoIn.pointSensorSafeRatio[3])
        {
           ui->lineEdit_pointCloud_safeRatio4->setStyleSheet("background-color: rgb(231, 231,0 );");
        }
        else
        {
            ui->lineEdit_pointCloud_safeRatio4->setStyleSheet("background-color: rgb(231, 0, 0);");
        }
    }
    isCheckBarrier=basicInfoIn.pointSensorCheckEnable;
    if(true==basicInfoIn.pointSensorCheckEnable)
    {

        ui->pushButton_toogleCheckBarrior->setText("当前检查避障");
    }
    else
    {
        ui->pushButton_toogleCheckBarrior->setText("当前不检查避障");
    }
//    ui->lineEdit_pointCloud_safe_check_allow_3->setText(QString::number(basicInfoReturn.pointSensorCheckEnable));

    //运动引擎状态
    int motionStatus=mapDelegate->getMotionEngineStatus();
    switch(motionStatus)
    {
    case 0:
    {
        ui->pushButton_moveToPosition->setStyleSheet("background-color: rgb(231, 0, 0);");
        break;
    }
    case 1:
    {
        ui->pushButton_moveToPosition->setStyleSheet("background-color: rgb(0, 231, 0);");
        break;
    }
    case 2:
    {
        ui->pushButton_moveToPosition->setStyleSheet("background-color: rgb(231, 231, 0);");
        break;
    }
    default:
    {
        ui->pushButton_moveToPosition->setStyleSheet("background-color: rgb(0, 0, 0);");
    }
    }


    return 1;

}

int MapView::showPositionInfo()
{
    PositionInfo_hmi positionCU1,positionQrcode,positionVmark;
    mapDelegate->getVehiclePositionInCU1(positionCU1);
    mapDelegate->getVehiclePositionInQRcode(positionQrcode);
    mapDelegate->getVehiclePositionInVmark(positionVmark);
    //positionCU1显示
    ui->textEdit_vehiclePosInCU1->clear();
    QString tmpLineStr;
    if(true==positionCU1.isUpdateSucess)
    {
        ui->textEdit_vehiclePosInCU1->append("成功");
    }
    else
    {
        ui->textEdit_vehiclePosInCU1->append("失败");
    }
    tmpLineStr="x=";
    tmpLineStr+=QString::number(positionCU1.position.x,10,3);
    ui->textEdit_vehiclePosInCU1->append(tmpLineStr);
    tmpLineStr="y=";
    tmpLineStr+=QString::number(positionCU1.position.y,10,3);
    ui->textEdit_vehiclePosInCU1->append(tmpLineStr);
    tmpLineStr="r=";
    tmpLineStr+=QString::number(positionCU1.position.rotate*180.0/M_PI,10,3);
    ui->textEdit_vehiclePosInCU1->append(tmpLineStr);
    tmpLineStr="score=";
    tmpLineStr+=QString::number(positionCU1.matchScore,10,3);
    ui->textEdit_vehiclePosInCU1->append(tmpLineStr);
    tmpLineStr="error=";
    tmpLineStr+=QString::number(positionCU1.maxMatchError,10,3);
    ui->textEdit_vehiclePosInCU1->append(tmpLineStr);

    //positionQrcode显示
    ui->textEdit_vehiclePosInQRcode->clear();
    if(true==positionQrcode.isUpdateSucess)
    {
        ui->textEdit_vehiclePosInQRcode->append("成功");
    }
    else
    {
        ui->textEdit_vehiclePosInQRcode->append("失败");
    }
    tmpLineStr="x=";
    tmpLineStr+=QString::number(positionQrcode.position.x,10,3);
    ui->textEdit_vehiclePosInQRcode->append(tmpLineStr);
    tmpLineStr="y=";
    tmpLineStr+=QString::number(positionQrcode.position.y,10,3);
    ui->textEdit_vehiclePosInQRcode->append(tmpLineStr);
    tmpLineStr="r=";
    tmpLineStr+=QString::number(positionQrcode.position.rotate*180.0/M_PI,10,3);
    ui->textEdit_vehiclePosInQRcode->append(tmpLineStr);

    //positionVmark显示
    ui->textEdit_vehiclePosInVmark->clear();
    if(true==positionVmark.isUpdateSucess)
    {
        ui->textEdit_vehiclePosInVmark->append("成功");
    }
    else
    {
        ui->textEdit_vehiclePosInVmark->append("失败");
    }
    tmpLineStr="x=";
    tmpLineStr+=QString::number(positionVmark.position.x,10,3);
    ui->textEdit_vehiclePosInVmark->append(tmpLineStr);
    tmpLineStr="y=";
    tmpLineStr+=QString::number(positionVmark.position.y,10,3);
    ui->textEdit_vehiclePosInVmark->append(tmpLineStr);
    tmpLineStr="r=";
    tmpLineStr+=QString::number(positionVmark.position.rotate*180.0/M_PI,10,3);
    ui->textEdit_vehiclePosInVmark->append(tmpLineStr);
    tmpLineStr="score=";
    tmpLineStr+=QString::number(positionVmark.matchScore,10,3);
    ui->textEdit_vehiclePosInVmark->append(tmpLineStr);
    tmpLineStr="error=";
    tmpLineStr+=QString::number(positionVmark.maxMatchError,10,3);
    ui->textEdit_vehiclePosInVmark->append(tmpLineStr);



    return 1;
}

int MapView::checkMap(QString runningMap)
{
    static bool messageFlag=false;
    //if(currentShowMapName!=runningMap &&""!=runningMap)
    if(0==runningMap.compare(""))
    {
        mapGraphicsView->hide();
        ui->label_noMapInformation->setText("未加载地图!!!");
    }
    else if(0!=currentShowMapName.compare(runningMap) && 0!=runningMap.compare(""))
    {
        QString tmpFilePath=D_MAP_PATH;
        tmpFilePath+=runningMap;

        if(1!=reloadMap())
        {
            mapGraphicsView->hide();
            ui->label_noMapInformation->setText("本地磁盘无对应地图文件！！！");
            if(false==messageFlag)
            {
                messageFlag=true;
//                emit msgBoxSignal(EM_MSG_BOX_SURE_BTN,tr("提示"),tr("没有找到当前地图,请重新登录下载地图"));
                if(mapDelegate->isUseFtpStatus())
                {
//                    QMessageBox message(QMessageBox::NoIcon, "提示", "本地没有找到地图文件，即将重新下载地图文件！"
//                                        , QMessageBox::Yes , NULL);
//                    if(message.exec() == QMessageBox::Yes)
//                    {
//                        getMapFile_slot();
//                    }
                    getMapImageFile();
                }

            }
            return -1;
        }
        else
        {
            reflectEditDialog->getAllReflectMarks();//如果本地有地图图片时，才会执行
            emit loginControllerSucess_signal();
            mapGraphicsView->show();
        }

//        std::vector<struct VehiclePosition> carBorderOffsetOut;
//        mapDelegate->getCarBorderOffset(carBorderOffsetOut);//获取有效边框
//        mapLogic->setCarBorderAndOffset(carBorderOffsetOut);
//        scene->setCarBorderRect(0,0,mapLogic->getCarWidth(),mapLogic->getCarHeight());
//        scene->update();
        currentShowMapName=runningMap;
        messageFlag=false;
        return 1;
    }
    return -1;
}

void MapView::on_pushButton_setLaserFilterType_clicked()
{
    int returnFlag;
    mapDelegate->setLaserIntensityFilterByType_visionMatch(ui->lineEdit_laserFilterType->text().toInt(),returnFlag);
    mapDelegate->setCurrentVMarkType(ui->lineEdit_vmark_type->text().toInt(),returnFlag);
}

void MapView::on_pushButton_saveVmarkFIle_clicked()
{
    int returnFlag;
    VMarkInfo infoIn;
    infoIn.comment=ui->lineEdit_vmark_comment->text().toStdString();
    infoIn.mapName=ui->lineEdit_vmark_mapName->text().toStdString();
    infoIn.vindex=ui->lineEdit_vmark_index_save->text().toInt();
    infoIn.vmarkType=ui->lineEdit_vmark_type_2->text().toInt();
    infoIn.pose_x=ui->lineEdit_vmark_in_world_x->text().toDouble();
    infoIn.pose_y=ui->lineEdit_vmark_in_world_y->text().toDouble();
    infoIn.pose_r=ui->lineEdit_vmark_in_world_r->text().toDouble();

    QString vmarkFileIn=ui->lineEdit_vmark_fileName->text();
    mapDelegate->createVMark(infoIn,vmarkFileIn.toStdString(),returnFlag);
}

void MapView::on_pushButton_updateVmarkInfoByFile_clicked()
{
    int returnFlag;
    mapDelegate->updateVMarkFile(ui->lineEdit_vmark_fileName->text().toStdString(),returnFlag);
}

void MapView::on_pushButton_getVmakrsInfo_clicked()
{

        std::vector<VMarkInfo> vmarkInfoOut;
        mapDelegate->getVmarkInfoList(vmarkInfoOut);

        model_vmarksInfoInfo->clear();
        //定义item
        QStandardItem* item = 0;
        VMarkInfo tmpVmarkInfo;
        int skipCount=8;
        int i=0;
        foreach(tmpVmarkInfo,vmarkInfoOut)
        {
            item = new QStandardItem("vindex");
            model_vmarksInfoInfo->setItem(i*skipCount+0,0,item);
            item = new QStandardItem(QString::number(tmpVmarkInfo.vindex));
            model_vmarksInfoInfo->setItem(i*skipCount+0,1,item);

            item = new QStandardItem("vmarkType");
            model_vmarksInfoInfo->setItem(i*skipCount+1,0,item);
            item = new QStandardItem(QString::number(tmpVmarkInfo.vmarkType));
            model_vmarksInfoInfo->setItem(i*skipCount+1,1,item);

            item = new QStandardItem("mapName");
            model_vmarksInfoInfo->setItem(i*skipCount+2,0,item);
            item = new QStandardItem(QString::fromStdString(tmpVmarkInfo.mapName));
            model_vmarksInfoInfo->setItem(i*skipCount+2,1,item);

            item = new QStandardItem("comment");
            model_vmarksInfoInfo->setItem(i*skipCount+3,0,item);
            item = new QStandardItem(QString::fromStdString(tmpVmarkInfo.comment));
            model_vmarksInfoInfo->setItem(i*skipCount+3,1,item);

            item = new QStandardItem("pose_x");
            model_vmarksInfoInfo->setItem(i*skipCount+4,0,item);
            item = new QStandardItem(QString::number(tmpVmarkInfo.pose_x,'f',3));
            model_vmarksInfoInfo->setItem(i*skipCount+4,1,item);

            item = new QStandardItem("pose_y");
            model_vmarksInfoInfo->setItem(i*skipCount+5,0,item);
            item = new QStandardItem(QString::number(tmpVmarkInfo.pose_y,'f',3));
            model_vmarksInfoInfo->setItem(i*skipCount+5,1,item);

            item = new QStandardItem("pose_r");
            model_vmarksInfoInfo->setItem(i*skipCount+6,0,item);
            item = new QStandardItem(QString::number(tmpVmarkInfo.pose_r,'f',3));
            model_vmarksInfoInfo->setItem(i*skipCount+6,1,item);

            i++;
        }

        ui->tableView_vmarkInfoList->setModel(model_vmarksInfoInfo);
        ui->tableView_vmarkInfoList->resizeColumnToContents(0);
        ui->tableView_vmarkInfoList->resizeColumnToContents(1);
        ui->tableView_vmarkInfoList->resizeColumnToContents(2);
        ui->tableView_vmarkInfoList->show();
}



void MapView::on_verticalSlider_speed_jog_sliderMoved(int position)
{
    ui->verticalSlider_speed_jog_Edit->setText(QString::number(position));
}

void MapView::on_verticalSlider_speed_jog_Edit_textChanged(const QString &arg1)
{
    ui->verticalSlider_speed_jog->setSliderPosition(arg1.toInt());
}

void MapView::on_verticalSlider_speed_jog_valueChanged(int value)
{
    ui->verticalSlider_speed_jog_Edit->setText(QString::number(value));
}

//void MapView::on_checkBox_ultrasonicCheckEnable_clicked(bool checked)
//{
//    int tmpReturn;
//    mapDelegate->setUltrasonicSensorCheckEnable(checked,tmpReturn);
//}

//void MapView::on_checkBox_pointCloudCheckEnable_clicked(bool checked)
//{
//    int tmpReturn;
//    mapDelegate->setPointCloudCheckEnable(checked,tmpReturn);
//}

void MapView::on_pushButton_loadMap_3_clicked()
{
    int returnFlag;
    //如果
    if(NULL!=ui->listWidget_mapList_remote->currentItem())
    {
        QString title = ui->listWidget_mapList_remote->currentItem()->text();
        qDebug()<<title;
        mapDelegate->setDefaultMapName(title.toStdString(),returnFlag);
    }
    QString tmpInfo;
    switch (returnFlag) {

    case 1:
        tmpInfo="设置缺省地图成功!";
        break;
    default:
        tmpInfo="设置缺省地图失败!";
        break;
    }
    QMessageBox::information(NULL,"提示",tmpInfo,tr("ＯＫ"));

}

int MapView::showTargetPoint(VehiclePosition posIn)
{
    VehiclePosition pos_old;
    //    scene->drawTargetPoint(basicInfoReturn.targetPosition.x,basicInfoReturn.targetPosition.y,basicInfoReturn.targetPosition.rotate);//todo
        //targetpoint
    if( fabs(pos_old.x-posIn.x)>0.01 || fabs(pos_old.y-posIn.y)>0.01 ||
            fabs(pos_old.rotate-posIn.rotate)>0.00001)
    {
        double tmp_x=posIn.x;
        double tmp_y=posIn.y;
        double tmp_a=posIn.rotate/M_PI*180.0;
        mapLogic->translateWorldPoint2ScenePoint(tmp_x,tmp_y,tmp_a,tmp_x,tmp_y,tmp_a);
        scene->drawTargetPoint(true,tmp_x,tmp_y,tmp_a);
    }
    pos_old=posIn;
    //    showPointsInMap_Slot();//消耗资源，不应该频繁调用，只是点修改时调用。
    return 1;
}

int MapView::showCurrentPath(VehiclePosition startPosition, std::vector<VehiclePosition> targetPosition, E_NAV_COMMAND currentPathType,
                             double &currentPathParameter1, double &currentPathParameter2)
{

    //todo 判断是否有变换

    switch(currentPathType)
    {
    case E_NAV_COMMAND_LINE:
    {
        scene->drawCurrentPath_line(startPosition,targetPosition.back());
        ui->label_currentMovingPath->setText("直线");
        break;
    }
    case E_NAV_COMMAND_ROTATE:
    {
        scene->drawCurrentPath_rotate(targetPosition.back());
        ui->label_currentMovingPath->setText("旋转");
        break;
    }
    case E_NAV_COMMAND_SPLINE:
    {

        if(1==targetPosition.size())
        {
            ui->label_currentMovingPath->setText("1样条曲线");
            scene->drawOneBezier(startPosition,targetPosition.back(),currentPathParameter1,currentPathParameter2);
        }
        else if(1<targetPosition.size())
        {
            ui->label_currentMovingPath->setText(QString::number(targetPosition.size())+"样条曲线");
            scene->drawContinuousBezier(startPosition,targetPosition,currentPathParameter1,currentPathParameter2);
        }


        break;
    }
    case E_NAV_COMMAND_AUTO:
    {
        ui->label_currentMovingPath->setText("自由路径");
        break;
    }
    case E_NAV_COMMAND_NONE:
    {
        ui->label_currentMovingPath->setText("无");
        break;
    }
    default:{
        ui->label_currentMovingPath->setText("未知路径");
        qDebug()<<"不支持的路径类型"<<currentPathType;
    }
    }

}

void MapView::on_checkBox_isShowLaserData_clicked(bool checked)
{
    mapDelegate->setUpdatePointCloud(checked);
    if(false==checked)
    {
        scene->hideLaserPoint();
    }
}

void MapView::on_pushButton_toogleCheckBarrior_clicked()
{
    int tmpReturn;
    bool isCheck=!isCheckBarrier;
    mapDelegate->setUltrasonicSensorCheckEnable(isCheck,tmpReturn);
    mapDelegate->setPointCloudCheckEnable(isCheck,tmpReturn);
}

void MapView::on_pushButton_bezier_clicked()
{

    VehiclePosition startPosition, targetPosition;
    double lengthRatio=ui->lineEdit_plength->text().toDouble();

    startPosition.rotate=ui->lineEdit_p1r->text().toDouble()*M_PI/180.0;
    targetPosition.rotate=ui->lineEdit_p2r->text().toDouble()*M_PI/180.0;

    startPosition.x=ui->lineEdit_p1x->text().toDouble();
    startPosition.y=ui->lineEdit_p1y->text().toDouble();

    targetPosition.x=ui->lineEdit_p2x->text().toDouble();
    targetPosition.y=ui->lineEdit_p2y->text().toDouble();



    scene->drawOneBezier(startPosition,targetPosition,lengthRatio,true);



}

void MapView::on_pushButton_bezier_addUserPoint1_clicked()
{
    double tmpX,tmpY,tmpA;
    scene->getWorldPosition(tmpX,tmpY,tmpA);
    ui->lineEdit_p1x->setText(QString::number(tmpX,'f',3));
    ui->lineEdit_p1y->setText(QString::number(tmpY,'f',3));
    ui->lineEdit_p1r->setText(QString::number(tmpA/M_PI*180,'f',3));
}

void MapView::on_pushButton_bezier_addUserPoint2_clicked()
{
    double tmpX,tmpY,tmpA;
    scene->getWorldPosition(tmpX,tmpY,tmpA);
    ui->lineEdit_p2x->setText(QString::number(tmpX,'f',3));
    ui->lineEdit_p2y->setText(QString::number(tmpY,'f',3));
    ui->lineEdit_p2r->setText(QString::number(tmpA/M_PI*180,'f',3));
}


void MapView::on_pushButton_fitIn_clicked()
{

    scaleRatio=1;
    updateMatrix();
    qDebug()<<"fitIn scaleRatio="<<scaleRatio;
}

void MapView::on_pushButton_download_all_map_clicked()
{
//    getMapFile_slot();
//    getMapImageFile();
    removeMapFile(currentShowMapName.toStdString());
    currentShowMapName="";
}

void MapView::on_pushButton_delectSelectedMap_clicked()
{
    QMessageBox message(QMessageBox::Question, "提示", "是否删除选中的地图文件！"
                        , QMessageBox::Yes|QMessageBox::No , NULL);
    if(message.exec() == QMessageBox::No)
    {
        return;
    }

    int returnFlag;
    if(NULL!=ui->listWidget_mapList_remote->currentItem())
    {
        QString title = ui->listWidget_mapList_remote->currentItem()->text();
        qDebug()<<title;
        mapDelegate->deleteMap(title.toStdString(),returnFlag);

        on_pushButton_update_map_list_clicked();
    }
}

void MapView::keyPressEvent(QKeyEvent *event)
{
    int tmpKey=event->key();
    bool isAutoRepeat=event->isAutoRepeat();
    jogKeyBoard_press(tmpKey,isAutoRepeat);

    zoomKeyBoard_press(tmpKey,isAutoRepeat);

    return QDialog::keyPressEvent(event);
}

void MapView::keyReleaseEvent(QKeyEvent *event)
{
    char tmpKey=event->key();
    bool isAutoRepeat=event->isAutoRepeat();
    jogKeyBoard_release(tmpKey,isAutoRepeat);



    return QDialog::keyReleaseEvent(event);
}

int MapView::getMapImageFile()
{
    MapPropertyInfo infoOut;
    mapDelegate->getMapPropertyInfo("",infoOut);

    QFile tmpFile;
    QString tmpImagePath=D_MAP_PATH;
    tmpImagePath+=QString::fromStdString(infoOut.imageName);
    tmpFile.remove(tmpImagePath);
    ftpManage->ftpGetFile(QString::fromStdString(infoOut.imageName), D_MAP_PATH, D_MAP_PATH);
    return 1;
}


int MapView::removeMapFile(std::string fileName)
{
    int returnFlag;
    QString  mapName=QString::fromStdString(fileName);

    QRegExp rx("(.*).yaml");
//    programStr.indexOf(rx);

    bool isMatch=rx.exactMatch(mapName);

    if(false==isMatch )
    {
        qDebug()<<"map file name error "<<mapName;
        returnFlag = -1;
        return -1;
    }



    QString mapOriginalName=rx.cap(1);



    //pgm file
    QString filePath = D_MAP_PATH + mapOriginalName+".pgm";
    QFile removeFile2(filePath);
    if(removeFile2.exists())
    {
        qDebug()<<"remove "<<filePath;
        // 删除文件前要先关闭文件，否则无法删除
        removeFile2.close();
        removeFile2.remove();
    }




    return 1;

}


int MapView::zoomKeyBoard_press(int tmpKey, bool isAutoRepeat)
{

    switch(tmpKey)
    {
    case Qt::Key_F1:
    {
        on_pushButton_zoomOut_clicked();
        break;
    }
    case Qt::Key_F2:
    {
        on_pushButton_zoomIn_clicked();
        break;
    }

    }
    return 1;
}
#define D_PRESSED_COUNT 10
int MapView::jogKeyBoard_press(int tmpKey, bool isAutoRepeat)
{
    if(false==ui->checkBox_jogEnable_keyboard->isChecked())
    {
         return 0;
    }
//    if(isAutoRepeat)
//    {
//        if('W'==tmpKey || 'X'==tmpKey ||'A'==tmpKey|| 'D'==tmpKey ||'Q'==tmpKey ||'E'==tmpKey
//                ||'Z'==tmpKey ||'C'==tmpKey||'J'==tmpKey ||'L'==tmpKey)
//        {
//            jogKeyPressedCount=D_PRESSED_COUNT;
//            qDebug()<<"isAutoRepeat jogKeyPressedCount"<<jogKeyPressedCount;
//        }
//         return 0;
//    }
    qDebug("*********MapView::keyPressEvent***************");
    // 空格:暂停　　(空格键值32)

    switch(tmpKey)
    {
    case 'W':
    {
        on_pushButton_front_trans_pressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'X':
    {
        on_pushButton_back_trans_pressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'J'://左平移
    {
        on_pushButton_left_trans_pressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'L'://右平移
    {
        on_pushButton_right_trans_pressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'A'://原地正旋转
    {
        on_pushButton_left_rotation_pressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'D'://原地反旋转
    {
        on_pushButton_right_rotation_pressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'Q'://前左
    {
        jogFrontLeftPressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'E'://前右
    {
        jogFrontRightPressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'Z'://后左
    {
        jogBackLeftPressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    case 'C'://后右
    {
        jogBackRightPressed();
        jogKeyBoardReleaseFlag=1;
        jogKeyPressedCount=D_PRESSED_COUNT;
        break;
    }
    }
    return 1;
}

int MapView::jogKeyBoard_release(char tmpKey, bool isAutoRepeat)
{
    if(false==ui->checkBox_jogEnable_keyboard->isChecked() )
    {
         return 0;
    }
    qDebug("*********MapView::keyReleaseEvent***************");

    if('W'==tmpKey || 'X'==tmpKey ||'A'==tmpKey|| 'D'==tmpKey ||'Q'==tmpKey ||'E'==tmpKey
            ||'Z'==tmpKey ||'C'==tmpKey||'J'==tmpKey ||'L'==tmpKey
            || Qt::Key_Space==tmpKey )
    {
        jogKeyBoardReleaseFlag=2;

    }
    return 1;
}

int MapView::jogKeyBoard_stopMonitor()
{
    //定时器多次没被重置，才执行停止。
    static int tmpCount=0;

    if(0==jogKeyBoardReleaseFlag)
    {
        return 0;
    }

    if(0<jogKeyPressedCount)
    {
         jogKeyPressedCount--;
         qDebug()<<"jogKeyPressedCount"<<jogKeyPressedCount;
    }


    if(2==jogKeyBoardReleaseFlag || 0==jogKeyPressedCount)
    {
        tmpCount++;
    }
    else if(1==jogKeyBoardReleaseFlag)
    {
        tmpCount=0;
    }
    else
    {
        return 0;
    }

    if(2==tmpCount)
    {
        qDebug()<<"key board jog stop valid!!!";
        jogFlag=0;
        int returnFlag;
        mapDelegate->manual_stop(returnFlag);
        tmpCount=0;
        jogKeyBoardReleaseFlag=0;
    }
    return 1;

}

void MapView::on_pushButton_resetAndServoOn_clicked()
{
    QMessageBox message(QMessageBox::Question, "提示", "是否复位报警并电机使能！"
                        , QMessageBox::Yes|QMessageBox::No , NULL);
    if(message.exec() == QMessageBox::No)
    {
        return;
    }
    int tmpReturn;
    mapDelegate->cleanAllMessage();
    mapDelegate->setAllManualServon(0,tmpReturn);
}

//void MapView::on_pushButton_clrMsgServoOn_clicked()
//{

//}

void MapView::on_checkBox_fleetMainWindow_clicked(bool checked)
{
#ifdef D_USE_FLEET_WINDOW
    if(checked)
    {
        static int tmpCount=0;
        mainWindowFleet->show();
        if(0==tmpCount)
        {
            g_windowShowManage->addWindow(mainWindowFleet,"路径地图监视");
            tmpCount++;
        }

    }
    else
    {
//        mainWindowFleet->hide();
    }
#endif
}

void MapView::on_pushButton_refreshMapProperty_clicked()
{
    ui->listWidget_mapProperty->clear();

    QString tmpInfo;
    MapPropertyInfo infoOut;
    mapDelegate->getMapPropertyInfo("",infoOut);

    ui->listWidget_mapProperty->addItem(QString::fromStdString(infoOut.mapName));

    ui->listWidget_mapProperty->addItem(QString::fromStdString(infoOut.imageName));

    tmpInfo="比例尺：";
    tmpInfo+=QString::number(infoOut.mapRatio);
    ui->listWidget_mapProperty->addItem(tmpInfo);

    tmpInfo="x偏移：";
    tmpInfo+=QString::number(infoOut.xOffset,'f',4);
    ui->listWidget_mapProperty->addItem(tmpInfo);
    tmpInfo="y偏移：";
    tmpInfo+=QString::number(infoOut.yOffset,'f',4);
    ui->listWidget_mapProperty->addItem(tmpInfo);
    tmpInfo="r偏移：";
    tmpInfo+=QString::number(infoOut.rOffset,'f',4);
    ui->listWidget_mapProperty->addItem(tmpInfo);

    tmpInfo="图片像素w：";
    tmpInfo+=QString::number(infoOut.imageWidth);
    ui->listWidget_mapProperty->addItem(tmpInfo);

    tmpInfo="图片像素h：";
    tmpInfo+=QString::number(infoOut.imageHeight);
    ui->listWidget_mapProperty->addItem(tmpInfo);

    tmpInfo="地图宽：";
    tmpInfo+=QString::number(infoOut.imageWidth*infoOut.mapRatio);
    ui->listWidget_mapProperty->addItem(tmpInfo);

    tmpInfo="地图长：";
    tmpInfo+=QString::number(infoOut.imageHeight*infoOut.mapRatio);
    ui->listWidget_mapProperty->addItem(tmpInfo);

}

void MapView::on_pushButton_bezier_byControlPoints_clicked()
{
    VehiclePosition startPosition, targetPosition,m1,m2;

    startPosition.x=ui->lineEdit_p1x->text().toDouble();
    startPosition.y=ui->lineEdit_p1y->text().toDouble();

    targetPosition.x=ui->lineEdit_p2x->text().toDouble();
    targetPosition.y=ui->lineEdit_p2y->text().toDouble();

    m1.x=ui->lineEdit_m1x->text().toDouble();
    m1.y=ui->lineEdit_m1y->text().toDouble();

    m2.x=ui->lineEdit_m1x->text().toDouble();
    m2.y=ui->lineEdit_m1y->text().toDouble();


    scene->drawOneBezierByControlPoints(startPosition,targetPosition,m1,m2);


}

void MapView::loginControllerSucess_slot()
{
    reflectEditDialog->getAllReflectMarks();
    emit  loginControllerSucess_signal();
}
